#include <Arduino.h>

void setup()
{
  for (int i = 8; i < 12; i++)
  {
    pinMode(i, OUTPUT);
  }
}

void clockwise(int num)
{
  for (int count = 0; count < num; count++)
  {
    for (int i = 8; i < 12; i++)
    {
      digitalWrite(i, HIGH);
      delay(300);
      digitalWrite(i, LOW);
    }
  }
}

void anticlockwise(int num)
{
  for (int count = 0; count < num; count++)
  {
    for (int i = 11; i > 7; i--)
    {
      digitalWrite(i, HIGH);
      delay(300);
      digitalWrite(i, LOW);
    }
  }
}

void loop()
{
  clockwise(512);
  delay(1000);
  anticlockwise(512);
}